package com.example.export.app.service.impl;

import com.example.export.annotation.CusExport;
import com.example.export.app.service.TestExportService;
import com.example.export.domain.entity.ExcelTest;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author PC
 */
@Component
public class TestExportServiceImpl implements TestExportService {
    @Override
    @CusExport(dataClass = ExcelTest.class)
    public List<ExcelTest> generatorDataForClass() {
        List<ExcelTest> excelTestList = new ArrayList<>();
        for (int j = 0; j < 100; j++) {
            ExcelTest excelTest = new ExcelTest();
            excelTest.setCode("testCode" + j);
            excelTest.setName("testName" + j);
            excelTest.setEnabledFlag(j % 2);
            excelTestList.add(excelTest);
        }
        return excelTestList;
    }

    @Override
    @CusExport(dynamicFlag = true)
    public List<Map<String, Object>> generatorDataForMap() {
        List<Map<String, Object>> excelTestList = new ArrayList<>();
        for (int j = 0; j < 100; j++) {
            Map<String, Object> item = new HashMap<>(3);
            item.put("code", "testCodeMap" + j);
            item.put("name", "testNameMap" + j);
            item.put("enabledFlag", j % 2);
            excelTestList.add(item);
        }
        return excelTestList;
    }
//
}
